package vip.xiaonuo.modular.manage.tsdatarecord.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.manage.tsdatarecord.entity.BaseDataFolder;
import vip.xiaonuo.modular.manage.tsdatarecord.service.BaseDataFolderService;

import javax.annotation.Resource;

/**
 * BaseDataFolderController
 *
 * @author JackLee
 * 2022/8/11 15:28
 */
@RestController
public class BaseDataFolderController {
    @Resource
    private BaseDataFolderService baseDataFolderService;

    @PostMapping("/baseDataFolder/add")
    public ResponseData add(@RequestBody BaseDataFolder folder) {
        return new SuccessResponseData(baseDataFolderService.add(folder));
    }

    @PostMapping("/baseDataFolder/edit")
    public ResponseData edit(@RequestBody BaseDataFolder folder) {
        baseDataFolderService.edit(folder);
        return new SuccessResponseData();
    }

    @PostMapping("/baseDataFolder/delete")
    public ResponseData delete(@RequestBody BaseDataFolder folder) {
        baseDataFolderService.delete(folder);
        return new SuccessResponseData();
    }

    @GetMapping("/baseDataFolder/tree")
    public ResponseData buildTree() {
        return new SuccessResponseData(baseDataFolderService.buildTree());
    }
}
